package org.hishenframework.core.data.jdbc.template;

import java.util.List;

public class Page<T> {
	/**
	 * 总记录数
	 */
	private long resultSize;
	/**
	 * 每页记录数量
	 */
	private long pageSize = 20;
	/**
	 * 总页数
	 */
	private long totalPages;
	/**
	 * 当前页码
	 */
	private long currentPage;
	/**
	 * 结果集
	 */
	private List<T> result;

	/**
	 * 刷新页面总数
	 */
	private void refreshPageCount() {
		this.totalPages = resultSize / pageSize;
		if(resultSize % pageSize > 0)
			this.totalPages++;
	}
	
	public long offSet() {
		return currentPage * (pageSize - 1);
	}
	
	public long getCount() {
		return resultSize;
	}

	public void setCount(long count) {
		this.resultSize = count;
		refreshPageCount();
	}

	public long getPageSize() {
		return pageSize;
	}

	public void setPageSize(long pageSize) {
		this.pageSize = pageSize;
		refreshPageCount();
	}

	public long getPageNumber() {
		return currentPage;
	}

	public void setPageNumber(long pageNumber) {
		this.currentPage = pageNumber;
	}

	public long getTotalCount() {
		return totalPages;
	}

	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}
}
